<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>收藏的商家</title>
    <link rel="stylesheet" href="../css/common.css">
    <link rel="stylesheet" href="../css/style_zj.css">
    <link rel="stylesheet" href="../layui/css/layui.css">
    <link rel="stylesheet" href="../fonts/iconfont.css">
</head>
<body>
<!--<div id="header_01_html">
    <iframe id="header_01" src="head_01.html" frameborder="0"></iframe>
</div>-->
<div class="content-box">
    <!--<div id="left_tab_html">
        <iframe id="left_tab" src="left_tab.html?x=3&y=5" frameborder="0"></iframe>
    </div>-->
    <div class="right-box layui-form" id="vue-box" v-cloak>
        <div class="friend-tips">
            <div class="title-box"><i class="icon-sty"></i><b class="title-tip">温馨提示</b></div>
            <div class="info-list">1、您可以在这里查看，管理您收藏的商家或产品</div>
            <div class="info-list">2、将您感兴趣的商家或产品加入收藏夹，登录后台直接查看</div>
        </div>
        <div class="content-admin">

            <div class="title-toggle">
                <div class="item"><a href="collection_product.html">收藏的产品</a></div>
                <div class="item active">收藏的商家</div>
            </div>
            <div>
                <div class="operation-title">
                    <span class="btn-sty22 mr-15 js-alldel">批量删除</span>
                </div>
                <div class="table-list">
                    <table>
                        <thead>
                        <tr>
                            <th class="js-allCheck">
                                <input type="checkbox" id="checkAll" name="" title="全选" lay-skin="primary" lay-filter="checkAll">
                            </th>
                            <th>名称</th>
                            <th>主营产品</th>
                            <!--<th>品类</th>-->
                            <th class="width_170">客服</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="item in pagList">
                            <td class="js-onlyCheck"><input type="checkbox" :id="item.zslStore.id" name="" lay-skin="primary" lay-filter="checkIt"></td>
                            <td>{{item.zslStore.name}}</td>
                            <td>
                                <span class="mr-8" v-for="data in item.zslStoreCommodityList">{{data.name}}</span>
                            </td>
                            <!--<td>完成</td>-->
                            <td class="col-sty1">
                                <a target="_blank" :href="'http://wpa.qq.com/msgrd?v=3&uin='+item.zslStore.qq+'&site=qq&menu=yes'">
                                    <img src="../img/QQ.png" class="qq-box1" align="absmiddle">
                                </a>
                            </td>
                            <td class="cur-p">
                                <a class="cur-p colo-blue" @click="delOnly(item.zslStore.id)">删除</a>
                                <div><a class="cur-p colo-blue" :href="Url + item.zslStore.id" target="_blank">查看</a></div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div id="test1" class="text-r"></div>
                </div>
            </div>
        </div>
    </div>
</div>

<!--<div>
    <iframe src="footer-record.html" style="width: 100%;border: none;height:60px;"></iframe>
</div>-->
<script src="../js/config.js"></script>

<script>
    var postData = {
        limit:4,
        offset:1,
    }

    var app = new Vue({
        el: '#vue-box',
        data: {
            pagList:'',
            imgBaseUrl: imgBaseUrl,
            Url:'http://www.ziselu.com/car/page/store.html?storeid='
        },
        mounted:function(){
            this.getPage();
        },
        updated:function () {
            layui.use('form', function(){
                var form = layui.form;
                form.render("checkbox");
            });
        },
        methods:{
            getPage:function(){
                var that = this;
                get_ajaxPage("/sys/follow/getMyFollowPage", postData, function (data) {
                    console.log(data);
                    that.pagList = data.data;
                    layui.use('laypage', function(){
                        var laypage = layui.laypage;
                        //执行一个laypage实例
                        laypage.render({
                            elem: 'test1'
                            ,count: data.count //数据总数，从服务端得到
                            ,limit:postData.limit
                            ,jump: function(obj, first){
                                //obj包含了当前分页的所有参数，比如：
                                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                                console.log(obj.limit); //得到每页显示的条数

                                //首次不执行
                                if(!first){
                                    //do something
                                    postData.offset = obj.curr;
                                    get_ajaxPage("/sys/storeCommodity/getMyPage", postData, function (data) {
                                        that.pagList = data.data;
                                    })
                                }
                            }
                        });
                    });
                })



            },
            delOnly:function(id){
                get_ajax("/sys/follow/delFollowByiIds", {id:id}, function (data) {
                    layer.msg('取消收藏成功！');
                    app.getPage();
                })
            }
        }
    });


    $('.js-alldel').click(function(){   //all-取消收藏
        var arr = [];
        $('tbody').find("input[type='checkbox']:checked").each(function(){
            arr.push($(this).attr('id'));
        })
        if(arr.length<1){
            layer.msg('请选择店铺')
            return
        }
        var arrStr = String(arr);
        get_ajax("/sys/follow/delFollowByiIds", {id:arrStr}, function (data) {
            console.log(data);
            layer.msg('取消收藏成功！');
            app.getPage();
            layui.use('form', function(){
                var form = layui.form;
                $("table input[type=checkbox]").prop("checked",false);
                form.render("checkbox");
            });
        })
    })

    layui.use('form', function(){  //2级联动
        var form = layui.form;
        form.render("checkbox");
        form.on('checkbox(checkAll)', function(data){    //layui-触发事件
            var checked = data.elem.checked;
            $("tbody input[type=checkbox]").prop("checked",checked);
            form.render("checkbox");
        });
        form.on('checkbox(checkIt)', function(data){
            var checked = data.elem.checked;
            var allLength = $("tbody input[type=checkbox]").length;
            var checkLength = $("tbody input[type=checkbox]:checked").length;
            $("#checkAll").prop("checked",allLength == checkLength);
            form.render("checkbox");
        });
    });
</script>
</body>
</html>